#pragma once

#include <gtl/ui/skins/pane.h>

namespace gtl
{

namespace skins
{

//////////////////////////////////////////////////////////////////////////
// xml:
//<panel id="tab1" type="app" bkcolor="#00FFFF">
//	<position x="100" y="100" width="800" height="300" />
//	<hittest>
//		<rect x="0" y="0" width="1024" height="35" />
//	</hittest>
//</panel>
//////////////////////////////////////////////////////////////////////////
class panel
	: public wnd
	, public container<panel, 'panl'>
{
	auto_reg_to_the_factory();

	enum wnd_type { wnd_child, wnd_modeless, wnd_modal, wnd_app, };

public:
	panel();
	virtual ~panel();

public:
	virtual unsigned int initialize(gtl::xml& node, wnd* parent_wnd);
	virtual void output(pane* pane_ptr, const gtl::tchar* action, const gtl::tchar* data, const gtl::tchar* provider);

	//virtual HRESULT GetTypeLib(LCID lcid, LPTYPELIB* ppTypeLib) { return 0; }

protected:
	void GetRect(CRect& rect, gtl::xml& node);
	void OnClose();

protected:
	DECLARE_MESSAGE_MAP()
	virtual LRESULT WindowProc(UINT message, WPARAM wParam, LPARAM lParam);
	afx_msg LRESULT OnNcHitTest(CPoint point);
	afx_msg void OnSize(UINT nType, int cx, int cy);
	afx_msg BOOL OnEraseBkgnd(CDC* pDC);
	afx_msg LRESULT OnWindowEvent(WPARAM wParam, LPARAM lParam);

protected:
	wnd_type	m_wnd_type;
	bool		m_adapt;
	bool		m_x_adapt;
	bool		m_y_adapt;
	COLORREF	m_bkclr;
	CBitmap*	m_bkimg;

	HWINEVENTHOOK m_hEventHook;
	std::vector<CRect> m_hittest_rects;
};

} // end of namespace skins

} // end of namespace gtl